{include file="head" /}

<!-- 编辑器引入开始 -->
<link href="/static/public/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="/static/public/umeditor/third-party/jquery.min.js"></script>
<script type="text/javascript" src="/static/public/umeditor/third-party/template.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/public/umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/public/umeditor/umeditor.min.js"></script>
<script type="text/javascript" src="/static/public/umeditor/lang/zh-cn/zh-cn.js"></script>

<!-- 编辑器引入结束 -->

{include file="menu" /}


<!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              
            
          <div class="row">
                  <div class="col-sm-12">
                      <aside class="profile-info col-lg-9">
                      <section class="panel">
                          
                          <div class="panel-body bio-graph-info">
                              <h1>{if isset($isedit) && $isedit == 1}编辑用户{else} 添加用户{/if}</h1>
                              <form class="form-horizontal" role="form" method="post" id="formid">

                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">用户名</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="{$username?$username:'系统生成'}" disabled="true" >
                                      </div>
                                  </div>

                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">手机号</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="{$utel?$utel:''}" name="utel">
                                      </div>
                                  </div>

                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">真实姓名</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="{$nickname?$nickname:''}" name="nickname">
                                      </div>
                                  </div>
								{if isset($isedit) && $isedit == 1}
                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">状态</label>
                                      <div class="col-lg-6">
                                          <select name="ustatus" class="selectpicker show-tick form-control">
                                          	  <option {if isset($ustatus) && $ustatus == 0} selected="selected" {/if} value="0">正常</option>
                                          	  <option {if isset($ustatus) && $ustatus == 1} selected="selected" {/if} value="1">冻结</option>
                                          </select>
                                      </div>
                                  </div>
								 {/if}
                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">邀请码</label>
                                      <div class="col-lg-6">
                                          <p>默认为自己的下线客户</p>
                                      </div>
                                  </div>
									{if isset($isedit) && $isedit == 1}


                                  

                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">账户余额</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="{$usermoney?$usermoney:'0'}" name="usermoney">
                                          <input type="hidden" class="form-control"  value="{$usermoney?$usermoney:'0'}" name="ordusermoney">
                                      </div>
                                  </div>
				
                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">新密码</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="" name="upwd">
                                      </div>
                                  </div>

                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">确认密码</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="" name="upwd2">
                                      </div>
                                  </div>
                                  <input type="hidden" class="form-control"  value="{$uid}" name="uid">
								{else/}
								<div class="form-group">
                                      <label class="col-lg-2 control-label">密码</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="" name="upwd">
                                      </div>
                                  </div>

                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">确认密码</label>
                                      <div class="col-lg-6">
                                          <input type="text" class="form-control"  value="" name="upwd2">
                                      </div>
                                  </div>
                                  <input type="hidden" class="form-control"  value="" name="ordpwd">
								{/if}
									

                                  

                                  <div class="form-group">
                                      <div class="col-lg-offset-2 col-lg-10">
                                          <input type="submit" value="提交"  onclick="return editcon(this.form)" class="btn btn-success">
                                          
                                      </div>
                                  </div>

                              </form>
                          </div>
                      </section>
                      
                  </aside>
                  </div>

          </div>       
          
          
             

          </section>
      </section>
      <!--main content end-->
  </section>


{include file="foot" /}
<script type="text/javascript" src="/static/public/umeditor/umindex.js"></script>
<script>

	function editcon(form){
		var type = "{$isedit}";
		var utel = form.utel.value;
		var nickname = form.nickname.value;
		var upwd = form.upwd.value;
		var upwd2 = form.upwd2.value;
		var ordpwd = form.ordpwd.value;

		if(type == 0 || (type == 1 && ordpwd)){ 
			if(!upwd){layer.msg('请输入密码'); return false;}
			if(upwd.length < 6){layer.msg('密码长度大于6位'); return false;}
			if(!upwd2){layer.msg('请再输入密码'); return false;}
			if(upwd !== upwd2){layer.msg('两次输入密码不同'); return false;}
		}

		if(type == 0){
			var formurl = "{:Url('user/useradd')}";
			if(!utel){layer.msg('请输入手机号'); return false;}
		}else{
			var formurl = "{:Url('user/useredit')}";
		}

		
		if(!nickname){layer.msg('请输入真实姓名'); return false;}
		
	    var data = $('#formid').serialize();
	    var locurl = "{:Url('user/userlist')}";

	    WPpost(formurl,data,locurl);

	    return false;
	}


</script>